import React, { Component } from 'react'
import { Text, View, Button } from 'react-native'
import { connect } from 'react-redux'
import { increment, decrement } from '../../redux/actions/counter'

const mapStateToProps = state => {
  return {
    num: state.Counter.num
  }
}

class Counter extends Component {
  constructor(props) {
    super(props)
  }

  render() {
    // console.log('counter', this.props)

    return (
      <View style={{flex:1,flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center'}}>
        <Button title={'-'} onPress={() => this.props.decrement(1)} />
        <Text >{this.props.num}</Text>
        <Button title={'+'} onPress={() => this.props.increment(1)} />
      </View>
    )
  }
}

export default connect(mapStateToProps, { increment, decrement })(Counter)
